<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<html>
<head>
	<title><s:text name="pl.grabar.clinic.client.web.admin.users.views.list-users"/></title>
	

<%--  	<link href="${pageContext.request.contextPath}/static/global/js/select2-3.4.5/select2.css" rel="stylesheet"/> --%>
<%-- 	<script type="text/javascript" src="${pageContext.request.contextPath}/static/global/js/select2-3.4.5/select2.js"></script> --%>
<%-- 	<script type="text/javascript" src="${pageContext.request.contextPath}/static/global/js/select2-3.4.5/select2_locale_pl.js"></script> --%>
	<sj:head jqueryui="true" jquerytheme="flick" locale="%{locale}"/>
	<link href="${pageContext.request.contextPath}/static/global/js/jquery-multiple-select/multiple-select.css" rel="stylesheet"/>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/global/js/jquery-multiple-select/jquery.multiple.select.js"></script>
	
	<script type="text/javascript">
		$(function() {
			userTypeMap={};
			$.each($("#idUserTypeMap").val().replace(/[{}]/g,"").split(","), function(){
				var tmp = this.split("=");
				userTypeMap[tmp[0].trim()] = tmp[1].trim();
			});
		});
	
	 	function createObjectUserTypeRow(cellvalue, options,row){
	 		return userTypeMap[cellvalue];
	 	}
	
	 	function createObjectActionsRow(cellvalue, options, row) {
	 		return "<a href='edit?userId=" + cellvalue +"&userType="+row.userType+ "'><s:text name='pl.grabar.clinic.client.web.buttons.edit'/></a>"
	 				+ "&nbsp;&nbsp;<a href='delete?userId=" + cellvalue + "&userType=" +row.userType + "'><s:text name='pl.grabar.clinic.client.web.buttons.delete'/></a>"
	 				+ "&nbsp;&nbsp;<a href='preview?userId=" + cellvalue + "&userType=" +row.userType + "'><s:text name='pl.grabar.clinic.client.web.buttons.preview'/></a>"
		}
	</script>
	<style type="text/css">
	
 .wwctrl { 
     border: 1px solid gray;
     margin-left:220px;
     }
	</style>
</head>
<body>
	<h1><s:text name="pl.grabar.clinic.client.web.admin.users.views.list-users"/></h1>
	<s:hidden id="idUserTypeMap" name="userTypes"/>
	
	<s:url var="loadUrl" action="load"/>
    <sjg:grid
	        id="gridtable"
	        dataType="json"
	        href="%{loadUrl}"
	        pager="true"
	        gridModel="data"
	        rowList="10,20,50,100"
	        rowNum="15"
	        rownumbers="true"
	        sortorder="asc"
	        autowidth="true"
	        shrinkToFit="true">
       <sjg:gridColumn name="userType" title="%{getText('pl.grabar.clinic.client.web.labels.user-type')}" sortable="false" formatter="createObjectUserTypeRow"/>
       <sjg:gridColumn name="lastName" title="%{getText('pl.grabar.clinic.client.web.labels.lastname')}" sortable="false"/>
       <sjg:gridColumn name="firstName" title="%{getText('pl.grabar.clinic.client.web.labels.firstname')}" sortable="false"/>
       <sjg:gridColumn name="login" title="%{getText('pl.grabar.clinic.client.web.labels.login')}" sortable="false"/>
       <sjg:gridColumn name="email" title="%{getText('pl.grabar.clinic.client.web.labels.email')}" sortable="false"/>
       <sjg:gridColumn name="phoneNumber" title="%{getText('pl.grabar.clinic.client.web.labels.phone-number')}" sortable="false"/>
       <sjg:gridColumn name="id" title="%{getText('pl.grabar.clinic.client.web.labels.actions')}" sortable="false" formatter="createObjectActionsRow" width="90"/>
    </sjg:grid>

<!-- 	<br></br> -->
	<s:select list="userTypes" name="idSelectedUserType" id="idSelectedUserType" label="%{getText('pl.grabar.clinic.client.web.labels.new-user')}" multiple="false" style="width: 300px;" />
	<br></br>
	<script type="text/javascript">
	$("#idSelectedUserType").multipleSelect({
		placeholder: "Wybierz  typ użytkownika",
		unselectRadio: true,
		single: true,
		onClick: function(view) {
			location.href='new?userType='+$('#idSelectedUserType').val();
        },
	});
   	</script>
</body>
</html>